#include "Window.h"

Window::Window() {
	mWindowSize = { 1920, 1080 };
	mPosition = { 0, 0 };
	mTitle = "DX11 Rendering Engine";
	mIsFullscreen = false;

	DEV_ASSERT(glfwInit(), "Window", "Failed to initialize GLFW.");

	glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
	glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);

	if (mIsFullscreen) {
		mWindow = glfwCreateWindow(mWindowSize.x, mWindowSize.y, mTitle.c_str(), glfwGetPrimaryMonitor(), nullptr);
	} else {
		mWindow = glfwCreateWindow(mWindowSize.x, mWindowSize.y, mTitle.c_str(), nullptr, nullptr);
	}

	glfwSetWindowUserPointer(mWindow, this);

	//glfwSetWindowSizeCallback(mWindow, [](GLFWwindow* window, int width, int height) {
	//	Window* windowPtr = (Window*)glfwGetWindowUserPointer(window);
	//	windowPtr->mWindowSize = { width, height };
	//	windowPtr->GetSwapchain()->Resize(width, height);
	//});
}

Window::~Window() {
	glfwTerminate();
}


void Window::ProcessMessage() {
	glfwSwapBuffers(mWindow);
	glfwPollEvents();
}